package com.momo.mapper.mapper.sysSetting;

import com.momo.mapper.dataobject.DeptDO;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * Created by MOMO on 2019/3/8.
 */
public interface DeptMapper {
    public int updateByPrimaryKeySelective(DeptDO entity);

    public DeptDO getDeptByUUID(String sys_dept_uuid);

    /**
     * desc:insertSelective.<br/>
     * descSql =  insert into sys_dept id, sys_dept_uuid, sys_dept_name, sys_dept_parent_id, sys_dept_level, sys_dept_seq, sys_is_leaf, sys_dept_status, sys_dept_remark, group_id, del_flag, create_by, create_time, update_time, update_by, #{id,jdbcType=BIGINT}, #{sysDeptUuid,jdbcType=VARCHAR}, #{sysDeptName,jdbcType=VARCHAR}, #{sysDeptParentId,jdbcType=BIGINT}, #{sysDeptLevel,jdbcType=VARCHAR}, #{sysDeptSeq,jdbcType=INTEGER}, #{sysIsLeaf,jdbcType=CHAR}, #{sysDeptStatus,jdbcType=CHAR}, #{sysDeptRemark,jdbcType=VARCHAR}, #{groupId,jdbcType=BIGINT}, #{delFlag,jdbcType=CHAR}, #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR},
     *
     * @param entity entity
     * @return int
     */
    public int insertSelective(DeptDO entity);

    /**
     * 新增/编辑：检测同一层级下是否有相同名称的部门
     *
     * @param parentId 父级id
     * @param deptName 部门名称
     * @param deptId       主键
     * @return
     */
    public int countByNameAndParentId(@Param("parentId") Long parentId, @Param("deptName") String deptName, @Param("deptId") Long deptId);

    /**
     * 检测当前部门是否是叶子节点
     *
     * @param deptLevel
     * @return
     */
    public int isLeaf(@Param("deptLevel") String deptLevel, @Param("needUpdateId") Long needUpdateId);

    public DeptDO selectByPrimaryKey(@Param("id") Long deptId);

    /**
     * 查询当前部门下的所有子部门(不包含自身)
     *
     * @param deptLevel
     * @return
     */
    public List<DeptDO> getChildDeptListByLevel(@Param("deptLevel") String deptLevel);

    /**
     * 批量更新部门level
     *
     * @param deptList
     * @return
     */
    public int batchUpdateLevel(@Param("sysDeptList") List<DeptDO> deptList);

    public List<DeptDO> getAllDept(Long groupId);
}
